package com.tjetc.dao.impl;

import com.tjetc.dao.UserDao;
import com.tjetc.pojo.entity.User;
import com.tjetc.utils.DruidUtils;
import org.apache.commons.dbutils.handlers.BeanHandler;

/**
 * @Author: itda
 * @Date: 2024/5/10 19:49
 * @Description: UserDaoImpl
 */
public class UserDaoImpl implements UserDao {
    @Override
    public User getByUserName(String username) throws Exception{
        return DruidUtils.r2.query("select * from user where username = ?", new BeanHandler<>(User.class), username);
    }

    @Override
    public void insert(User user) throws Exception{
        DruidUtils.r1.update(DruidUtils.getConnection(),"insert into user (username, password, email, gender, phone) VALUES " +
                "(?,?,?,?,?)", user.getUsername(),user.getPassword(),user.getEmail(),user.getGender(),user.getPhone());
    }
}
